#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 
#include <sys/socket.h> 
#include <netinet/in.h> 
#include <string.h> 
#include <pthread.h> 


int main()//client code 
{ 
	int fd; 
	int sockfd; 
	int ret;
	struct sockaddr_in myaddr, clientaddr; 

	char buf[100]=""; 
	int len = sizeof(clientaddr); 
	bzero(&clientaddr, sizeof(clientaddr)); 
	bzero(&myaddr, sizeof(myaddr)); 
	myaddr.sin_family = AF_INET; 
	myaddr.sin_port = htons(2222); 
	myaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); 

	if((sockfd = socket(AF_INET, SOCK_DGRAM, 0))<0) 
	{ 
		perror("socket"); 
		exit(1);     
	} 

	ret = sendto(sockfd, "hello!", 10, 0, (struct sockaddr*)&myaddr, len); 
	if(ret < 0)
		printf("sfefef\n");
	printf("===============\n");
	recvfrom(sockfd, buf, 100, 0, (struct sockaddr*)&myaddr, &len); 
	printf("recv:%s\n",buf); 


	return fd; 
} 
